/**
 *
 * @author zzhijie
 * @date 2021-04-23
 */
export default {
  name: 'f-btn',
  props: {
    permission: {
      type: [String, Array],
      default: ''
    }
  },
  data() {
    let config = this.$crudConfig || {};
    let {permissions = []} = config;
    return {
      permissions: permissions
    }
  },
  computed: {
    hasPermission() {
      if (!this.permission) {
        return true;
      } else {
        if (this.permissions.includes('*:*:*')) return true;
        let isArray = Array.isArray(this.permission);
        return this.permissions.some(permission => {
          return isArray ? this.permission.includes(permission) : permission === this.permission;
        });
      }
    },
  },
  mounted() {

  },
  render() {
    return (
      this.hasPermission &&
      <el-button {...this.$attrs} v-slots={this.$slots}/>
    )
  }
}
